﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;

namespace TMCM.Engine
{
  public class Comport : SerialPort
  {

    public Comport(): base() {}
    public Comport(string portName) : base(portName) { }
    public Comport(string portName, int baudRate) : base(portName,baudRate) { }
    public Comport(string portName, int baudRate, Parity parity) : base(portName, baudRate, parity) { }
    public Comport(string portName, int baudRate, Parity parity, int dataBits) : base(portName, baudRate, parity, dataBits) { }
    public Comport(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) : base(portName, baudRate, parity, dataBits, stopBits) { }

    public new void Open()
    {
      try
      {
        base.Open();

        GC.SuppressFinalize(BaseStream);
      }
      catch
      {
      }
    }

    public new void Dispose()
    {
      Dispose(true);
    }

    protected override void Dispose(bool disposing)
    {
      try
      {

        GC.ReRegisterForFinalize(BaseStream);
      }
      catch
      {
      }

      base.Dispose(disposing);
    }
  }
}
